package org.esprit.ocm.client.ui.ec2;

import org.esprit.ocm.client.ui.common.Login;

import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.events.CloseClickHandler;
import com.smartgwt.client.widgets.events.CloseClientEvent;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.ButtonItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
import com.smartgwt.client.widgets.form.fields.events.ClickHandler;

public class CreateAccount extends Window{

	public CreateAccount() {
		setWidth(300);
		setHeight(200);
		setTitle("Account Window");
		setShowMinimizeButton(false);
		setIsModal(true);
		setShowModalMask(true);
		setShowCloseButton(false);
		centerInPage();
		addCloseClickHandler(new CloseClickHandler() {
			public void onCloseClick(CloseClientEvent event) {
				destroy();
			}
		});
		
		final DynamicForm formAccount = new DynamicForm();
		formAccount.setWidth(250);
		formAccount.setHeight(150);
		formAccount.setPadding(5);
		formAccount.setLayoutAlign(VerticalAlignment.TOP);

		TextItem username = new TextItem("username");
		username.setTitle("Username");
		username.setRequired(true);

		TextItem password = new TextItem("password");
		password.setTitle("Password");
		password.setRequired(true);
		
		TextItem password2 = new TextItem("password");
		password2.setTitle("Retype Password");
		password2.setRequired(true);
		
		TextItem email = new TextItem("email");
		email.setTitle("Email");
		email.setRequired(true);


		ButtonItem createButton = new ButtonItem("create", "Create");
		createButton.addClickHandler(new ClickHandler() {

			public void onClick(ClickEvent event) {
				destroy();
//				hide();
				Login login = new Login();
				login.show();
				SC.say("Thank you for registration, Login now!");
			}
		});
		
		formAccount.setFields(username, email, password, password2, createButton);
		formAccount.redraw();

		addItem(formAccount);
	}
}
